package hu.myai.gui;

import hu.myai.api.indicators.IndicatorConsumerInterface;
import hu.myai.api.tick.TickProviderInterface;
import hu.myai.api.triggers.TriggerConsumerInterface;
import hu.myai.indicators.LowerBollingerIndicator;
import hu.myai.indicators.tick.TickIndicator;
import hu.myai.tick.ZippedMetastockTick;
import hu.myai.triggers.bearish.SupportCrossTrigger;
import hu.myai.triggers.bullish.ResistanceCrossTrigger;
import hu.myai.util.Constans;
import hu.myai.util.pool.IndicatorPool;

public class MyaiPlugin {

	TickProviderInterface myTick;

	public TickProviderInterface initTick(IndicatorConsumerInterface consumer) {

		ZippedMetastockTick tick = new ZippedMetastockTick("zipTick");
		tick.setInitDate("2009-05-05");
		tick.setSymbol("EURUSD");
		tick.setTimeScale(5);
		Constans.dataPath = "c:/Java/workspace/MyAI_NG/data/forexite/";

		// clear the pool
		IndicatorPool.clear(tick.getName());

		// LastHigherHighIndicator high = new LastHigherHighIndicator(2.0);
		// high.setNoize(4);
		// IndicatorPool.indicatorManager(high, tick);
		// high.addIndicatorConsumer(consumer);

		// LastLowerLowIndicator low = new LastLowerLowIndicator(2.0);
		// low.setNoize(4);
		// IndicatorPool.indicatorManager(low, tick);
		// low.addIndicatorConsumer(consumer);

		// UpperBollingerIndicator upBol = new UpperBollingerIndicator(20.0);
		// IndicatorPool.indicatorManager(upBol, tick);
		// upBol.addIndicatorConsumer(consumer);

//		 LowerBollingerIndicator lowBol = new LowerBollingerIndicator(20.0);
//		 IndicatorPool.indicatorManager(lowBol, tick);
//		 lowBol.addIndicatorConsumer(consumer);

//		 DecodeResistanceIndicator res = new DecodeResistanceIndicator(2.0);
//		 IndicatorPool.indicatorManager(res, tick);
//		 res.addIndicatorConsumer(consumer);

//		DecodeSupportIndicator sup = new DecodeSupportIndicator(2.0);
//		IndicatorPool.indicatorManager(sup, tick);
//		sup.addIndicatorConsumer(consumer);

//		ResAvgDirectionIndicator resAvg = new ResAvgDirectionIndicator(2.0);
//		IndicatorPool.indicatorManager(resAvg, tick);
//		resAvg.addIndicatorConsumer(consumer);
		
		TickIndicator dummy = new TickIndicator(TickIndicator.PIVOTPOINT);
		IndicatorPool.indicatorManager(dummy, tick);
		dummy.addIndicatorConsumer(consumer);

		ResistanceCrossTrigger resCrossTrigger = new ResistanceCrossTrigger("bullish_crossTrigger", tick);
		resCrossTrigger.setResistanceLevelIndicatorParameter(5.0);
		resCrossTrigger.addTriggerConsumer((TriggerConsumerInterface)consumer);

		SupportCrossTrigger supCrossTrigger = new SupportCrossTrigger("bearish_crossTrigger", tick);
		supCrossTrigger.setSupportLevelIndicatorParameter(5.0);
		supCrossTrigger.addTriggerConsumer((TriggerConsumerInterface)consumer);

		myTick = tick;
		return tick;
	}

	public void start() {
		myTick.start();
	}
}
